package Network;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

public class UdpDicServer extends UdpEchoServer{
    private HashMap<String,String> dic = new HashMap<>();
    public UdpDicServer(int port) throws SocketException {
        super(port);
        dic.put("cat","小猫");
        dic.put("dog","小狗");
        dic.put("rabbit","小兔");
    }

    @Override
    public String process(String request) {
        return dic.getOrDefault(request,"该词没有查询到");
    }

    public static void main(String[] args) throws IOException {
        UdpDicServer udpDicServer = new UdpDicServer(9090);
        udpDicServer.start();
    }
}
